<template>
    <div class="container">
        <Divider orientation="left">设定要件</Divider>
        <div v-for="(item,index) in yaoJianList" :key="index" class="tag-box">
            <Form :model="item" label-position="right">
                <Row>
                    <Col span="24">
                        <FormItem prop="yj_title" label="要件名称:">
                            {{item.yj_title}}
                        </FormItem>
                    </Col>
                    <Col span="8">
                        <FormItem prop="yj_type" label="要件类型:">
                           <!-- <span v-if="item.yj_type == '1'">表单</span>-->
                            <span v-if="item.yj_type == '1'">附件</span>
                            <span v-if="item.yj_type == '2'">制式表单</span>
                            <span v-if="item.yj_type == '3'">制式文本</span>
                        </FormItem>
                    </Col>
                    <Col span="8">
                        <FormItem prop="yi_img_demo" label="要件样本：">
                            <Button size="small" @click="uploadImgAction(item)">查看要件</Button>
                        </FormItem>
                    </Col>
                    <Col span="8">
                        <FormItem prop="is_fu_yong" label="是否可复用要件:">
                            <span v-if="item.is_fu_yong == '是'">是</span>
                            <span v-if="item.is_fu_yong == '否'">否</span>
                        </FormItem>
                    </Col>
                    <Col span="8">
                        <FormItem prop="is_xian_chang_cai_ji" label="是否现场采集:">
                            <span v-if="item.is_xian_chang_cai_ji == '是'">是</span>
                            <span v-if="item.is_xian_chang_cai_ji == '否'">否</span>
                        </FormItem>
                    </Col>
                    <Col span="8">
                        <FormItem prop="upload_type" label="上传方式:">
                            {{item.file_type}}
                        </FormItem>
                    </Col>
                    <Col span="24">
                        <FormItem prop="" label="要件依据:">
                            {{item.yj_yi_ju}}
                        </FormItem>
                    </Col>
                </Row>
                <br/>
                <br/>
            </Form>
        </div>
        <yao-jian-file-show-modal v-if="modalShow" ref="yaoJianFileShowModal"></yao-jian-file-show-modal>
    </div>
</template>

<script>
import { selectByNode } from '@/api/setting'
import YaoJianFileShowModal from './components/yao-jian-file-show-modal'

export default {
  name: 'YaoJianDetail',
  components: { YaoJianFileShowModal },
  data () {
    return {
      yaoJianList: [],
      baseID: '',
      modalShow: false
    }
  },
  props: {
    nodeId: {
      type: String,
      default: () => {
        return ''
      }
    }
  },
  methods: {
    success (val) {
      val = this.$common.xeUtils.isEmpty(val) ? '操作成功' : val
      this.$Message.success(val)
    },
    error (data) {
      this.$Message.error({
        content: '操作失败,\n' + data.errmsg
      })
    },
    getInfoByID () {
      const param = { base_info_id: this.baseID, gov_flow_id: this.nodeId }
      this.modalShow = false
      selectByNode('GovYaojian', param).then(ret => {
        let data = ret.data
        if (data.errcode === 0) {
          this.yaoJianList = data.data
          this.modalShow = true
        } else {
          this.error(data)
        }
      })
    },
    uploadImgAction (item) {
      this.$refs.yaoJianFileShowModal.modelAction(item.yi_img_demo)
    }
  },
  mounted () {
    this.baseID = this.$route.query.id
    this.getInfoByID()
  }
}
</script>

<style scoped>
    .container {
        padding: 20px;
    }

</style>
